# -*- coding: utf-8 -*-

from app import log

import time
from app import config
LOG = log.get_logger()

class Benchmark(object):
    def __init__(self):
        pass

    def process_request(self, req, res, resource=None):
        """
        Handle post-processing of the response (after routing).
        """
        if config.APP_ENV != 'live':
            req.context['req_time'] = time.time()
        # pass

    def process_response(self, req, res, resource=None):
        """
        Handle post-processing of the response (after routing).
        """
        if req.context.get('req_time'):
            process_time = time.time() - req.context['req_time']
            res.set_headers({'process_time':process_time})

